package com.you.modules.user.dao.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.you.modules.user.dao.IUserInfoDao;
import com.you.modules.user.mapper.UserInfoMapper;
import com.you.modules.user.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("userInfoDao")
public class UserInfoDaoImpl implements IUserInfoDao {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Override
    public UserInfo get(Integer id) {
        return userInfoMapper.selectById(id);
    }

    @Override
    public UserInfo save(UserInfo userInfo) {
        Integer row=userInfoMapper.insert(userInfo);
        return userInfo;
    }

    @Override
    public List<UserInfo> findAll() {
        return userInfoMapper.selectList(new EntityWrapper<UserInfo>());
    }

    @Override
    public List<UserInfo> findByUsername(String username) {
        return userInfoMapper.selectList(new EntityWrapper<UserInfo>().eq("username",username));
    }
}
